package
{
	import flash.geom.Point;
	
	public class GameGlobals
	{
		public static const SLICE_WIDTH:int = 290;
		public static const SLICE_HEIGHT:int = 146;
		public static const VIEW_SLICE_ROW_NUM:int = 7;
		public static const VIEW_SLICE_COL_NUM:int = 5;
		
		public static const TOTAL_SLICE_ROW_NUM:int = 9;	
		public static const TOTAL_SLICE_COL_NUM:int = 11;
		
		public static const NET_DATA_GET_PLAYER_ID:int = 1;
		public static const NET_DATA_PLAYER_ID_RET:int = 2;	
		
		public static const NET_DATA_PLAYER_INFO:int = 3;
		public static const NET_DATA_NEW_PLAYER_LIST:int = 4;		
		
		public static const NET_DATA_CHAT:int          =5;
		public static const NET_DATA_PLAYER_OUT:int     = 6;
		
		public static function getDirection(current:Point , target:Point):int 
		{
			var ret:int = 0;
			var iXD:int = (int)(target.x - current.x);
			var iYD:int = (int)(target.y - current.y);
			
			var iXLen:int = iXD * iXD;
			var iYLen:int = iYD * iYD;
			if (iXD == 0)
			{
				if (iYD > 0)
				{
					ret = 4;
				}
				else if (iYD < 0)
				{
					ret = 0;
				}
			}
			else if (iYD == 0)
			{
				if (iXD > 0)
				{
					ret = 2;
				}
				else if (iXD < 0)
				{
					ret = 6;
				}
			}
			else if (iXD > 0)
			{
				if (iYD > 0)
				{
					if (iXLen * 6 < iYLen)
					{
						ret = 4;
					}
					else if (iYLen * 6 < iXLen)
					{
						ret = 2;
					}
					else
					{
						ret = 3;
					}
				}
				else
				{
					if (iXLen * 6 < iYLen)
					{
						ret = 0;
					}
					else if (iYLen * 6 < iXLen)
					{
						ret = 2;
					}
					else
					{
						ret = 1;
					}
				}
			}
			else
			{
				if (iYD > 0)
				{
					if (iXLen * 6 < iYLen)
					{
						ret = 4;
					}
					else if (iYLen * 6 < iXLen)
					{
						ret = 6;
					}
					else
					{
						ret = 5;
					}
				}
				else
				{
					if (iXLen * 6 < iYLen)
					{
						ret = 0;
					}
					else if (iYLen * 6 < iXLen)
					{
						ret = 6;
					}
					else
					{
						ret = 7;
					}
				}
			}
			return ret;
		}		
	}
}